package Training.Threadtest01;

public class ThreadTickets01 extends Thread{
    private int bankno = 3;
    public void run(){
        while(true){
            synchronized (this){
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                if(bankno>0){
                    System.out.println(Thread.currentThread().getName() + " " + bankno);
                    bankno--;
                }
                else{
                    break;
                }
            }

        }
    }
}
